<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta name="author" content="王劲翔" />
		<title>Document</title>
	</head>
	<body>
		<img src="./images/b01.jpg" alt="" />
		<script>
			let arr = [
				"./images/b01.jpg",
				"./images/b02.jpg",
				"./images/b03.jpg",
				"./images/b04.jpg",
				"./images/b05.jpg",
				"./images/b06.jpg",
				"./images/b07.jpg",
				"./images/b08.jpg",
				"./images/b09.jpg",
				"./images/b10.jpg"
			]
			shufflingIMG("img", arr, 1000, true)
			function shufflingIMG(
				imgElement,
				arrURL = [],
				interval = 1000,
				cycle = false
			) {
				let index = 0
				imgElement = document.querySelector(imgElement)
				let time = setInterval(function () {
					imgElement.src = arrURL[index]
					if (++index == arrURL.length) {
						index = 0
						if (!cycle) {
							clearInterval(time)
						}
					}
				}, interval)
			}
		</script>
	</body>
</html>
